//
//  LBReactSinglePatcher.h
//  LBReactPatcher
//
//  Created by WuShiHai on 19/5/24.
//  Copyright (c) 2019 Lebbay All rights reserved.
//

#import <Foundation/Foundation.h>

#import <LBDownloader/LBDownloader.h>
#import <LBReact/LBReact.h>

#import "LBReactPatcher.h"
#import "LBReactPatcherModel.h"
#import "LBReactPatcherResponseModel.h"

typedef void (^LBReactPatcherCompleteBlock)(BOOL isSuccess);

@interface LBReactSinglePatcher : NSObject

/**
 实例

 @return 实例
 */
+ (instancetype)manager;

/**
 开启加载补丁包、检查补丁包、保存等事物
 
 @param mode 运行模式
 @param isBackground 是否后台操作, !isBackground & response 才会加载渲染，否则均后台下载提示
 @param launchOptions 启动项
 @param response 如果上层传入response，则使用该数据，否则调用接口
 @param progress 下载进度
 @param complete 任务完成后的回调，是否成功渲染了资源
 */
- (void)start:(LBReactBridgeMode)mode
 isBackground:(BOOL)isBackground
launchOptions:(NSDictionary *)launchOptions
     response:(NSDictionary *)response
     progress:(LBDownloadProgressBlock)progress
     complete:(LBReactPatcherCompleteBlock)complete;

/**
 获取将要或者已经渲染的补丁包
 
 @return 补丁包
 */
- (LBReactPatcherModel *)renderPatcher;

/**
 注册app加载完后的回调
 
 @param renderJSBlock js加载完成
 @param renderPageBlock page加载完成
 */
- (void)registerJSCallback:(LBReactBridgeJSCallbackBlock)renderJSBlock
           renderPageBlock:(LBReactBridgeJSCallbackBlock)renderPageBlock;

/**
 开启前后台切换的监听
 
 @param rootViewController rootViewController
 */
- (void)appDidEnterMainPage:(UIViewController *)rootViewController;

/**
 加载开发中的react native

 */
- (void)renderDevelopment;

/**
 根据资源名称进行渲染

 @param name index.app 或者index.stable.ios
 */
- (void)renderWithSourceName:(NSString *)name;

@end
